package com.sls.game.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sls.game.dao.EBaiMiDAO;
import com.sls.game.page.Pagination;
import com.sls.game.pojo.ebaimi.EbaimiProduct;

@Repository("eBaiMiDAO")
public class EBaiMiDAOImpl extends SuperDAO<EbaimiProduct> implements EBaiMiDAO {

	@Override
	public void insert(EbaimiProduct eInfo) {
		this.getSqlSession().insert("mybatis.xml.EbaimiProductMapper.insert",
				eInfo);
	}

	@Override
	public void update(EbaimiProduct eInfo) {
		this.getSqlSession().update("mybatis.xml.EbaimiProductMapper.update",
				eInfo);
	}

	@Override
	public EbaimiProduct queryById(String id) {
		return this.getSqlSession().selectOne(
				"mybatis.xml.EbaimiProductMapper.selectByPrimaryKey", id);
	}

	@Override
	public Pagination<EbaimiProduct> queryPaginationList(EbaimiProduct eInfo) {
		Pagination<EbaimiProduct> paginationList = null;
		Integer rowCount = queryRowCount(eInfo);

		eInfo.calculate();
		List<EbaimiProduct> list = queryGoodsInfoList(eInfo);
		paginationList = this.queryPagination(rowCount, list, eInfo);
		return paginationList;
	}

	@Override
	public List<EbaimiProduct> queryAllJpayInfo(EbaimiProduct isAudit) {
		return this.getSqlSession().selectList(
				"mybatis.xml.EbaimiProductMapper.queryAllEbaiMiInfo", isAudit);
	}

	@Override
	public EbaimiProduct queryByGoodsId(String goodsId) {
		return this.getSqlSession().selectOne(
				"mybatis.xml.EbaimiProductMapper.queryByGoodsId", goodsId);
	}

	/**
	 * 查询记录总数
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private Integer queryRowCount(EbaimiProduct info) {
		Integer rowCount = this.getSqlSession().selectOne(
				"mybatis.xml.EbaimiProductMapper.queryRowCount", info);
		return rowCount;
	}

	/**
	 * 记录结果集list
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private List<EbaimiProduct> queryGoodsInfoList(EbaimiProduct info) {
		List<EbaimiProduct> list = this.getSqlSession().selectList(
				"mybatis.xml.EbaimiProductMapper.queryEBaiMiGoodsInfoList",
				info);
		return list;
	}

	/**
	 * 商品删除
	 * 
	 * @param eInfo
	 */
	@Override
	public void deleteGoods(EbaimiProduct eInfo) {
		this.getSqlSession().delete(
				"mybatis.xml.EbaimiProductMapper.deleteGoods", eInfo);
	}
}
